package org.sensation.server.send;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

import org.sensation.server.operation.request.Command;

public class Contactor {
	private Socket socket;
	private ObjectOutputStream objectOutput;
	
	public Contactor() throws IOException {
		super();
		socket = new Socket();
		OutputStream outputStream = socket.getOutputStream();
		objectOutput = new ObjectOutputStream(outputStream);
	}


	public Command call(Command command) throws IOException, ClassNotFoundException {
		objectOutput.writeObject(command);
		InputStream inputStream = socket.getInputStream();
		ObjectInputStream objectInput = new ObjectInputStream(inputStream);
		return (Command) objectInput.readObject();
	}
}
